﻿<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <script src="assets/layui.js"></script>
    <script src="../js/jquery2.1.4.js"></script>
    <script src="layer/layer.js"></script>
    <script src="./qrcode/jquery2.1.4.js"></script>
    <script src="js/index.js" data-main="login"></script>
    <script src="js/login.js" data-main="login"></script>

    <link rel="stylesheet" href="assets/css/layui.css">
    <link rel="stylesheet" href="assets/css/login.css">
    <link rel="icon" href="/favicon.ico">
    <title>快递e栈管理后台</title>
</head>
<body class="login-wrap">
    <div class="login-container">
    	<h3>快递e栈后台管理</h3>
        <form class="login-form" action="index.html">
            <div class="input-group">
                <input type="text" id="username" class="input-field">
                <label for="username" class="input-label">
                    <span class="label-title">用户名</span>
                </label>
            </div>
            <div class="input-group">
                <input type="password" id="password" class="input-field">
                <label for="password" class="input-label">
                    <span class="label-title">密码</span>
                </label>
            </div>
            <button type="button" class="login-button">登录<i class="ai ai-enter"></i></button>
        </form>
    </div>
</body>

</html>
<script src="../layer/layer.js"></script>
<script type="text/javascript" >

    function go(){
        layer.msg("点击到了");
    }
    $(function(){
        $(".login-button").click(function(){
            var username = $("#username").val();
            var password = $("#password").val();
            var flag = checkAll(username,password);
            if(flag == true){
                //1.先试用layer,弹出load(提示加载中)
                //2.ajax 与服务器进行交互
                //3.关闭load窗口
                //4.将服务器回复的结果进行显示
                var windowId = layer.load(0);
                $.post("login.do",{username:username,password:password},function(data){
                    //3.关闭窗口
                    layer.close(windowId);
                    //4.将服务器回复的结果进行显示
                    layer.msg(data.result);
                    if(data.status == 0){
                        //跳转到主页
                        location.assign("index.html");
                    }
                },"JSON");
            }
        });
    });

    function checkAll( username, password){
        if(username == ""){
            layer.msg("用户名为空！",{icon:0,shade:0.02});
            return false;
        }else if(/^[a-zA-Z]\w{4,}/.test(username)==false){
            layer.msg("用户名长度必须大于5位",{icon:0,shade:0.02});
            return false;
        }
        else if(password == "" || password.length<0){
            layer.msg("密码为空！",{icon:0,shade:0.02});
            return false;
        } else if(/^[0-9]\w{2,}/.test(password)==false){
            layer.msg("密码格式有误",{icon:0,shade:0.02});
            return false;
        }
        return true;
    }
</script>